package com.itm.lqm.servlets.grade;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.itm.lqm.service.GradeService;


/**
 * Servlet implementation class deleteGradeByGid
 */
@WebServlet("/deleteGradeByGid")
public class deleteGradeByGid extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public deleteGradeByGid() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		
		int gid=Integer.parseInt(request.getParameter("gid"));
		System.out.println("sid的值是多少"+gid);
		
		
		//int  sno= Integer.parseInt(s); //把获取到的String类型的学号转化为int类型
		
		GradeService cs=new GradeService();
		boolean result=cs.deleteGradeByGid(gid);
		
		System.out.println(result);
		
		if(result){
			request.getRequestDispatcher("findAllGrade").forward(request, response);
		}else{
			response.sendRedirect("add.jsp");
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
